import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
import {getLoginUserUsingGet} from "@/api/user"
/* *
*存储用户信息的状态
{*/
export const userLoginStore = defineStore('loginUser', () => {
  const loginUser = ref({
    id: "",
    userAccount: "",
    userAvatar: "",
    userName: "",
    userProfile: "",
    userRole: "",
    createTime: "",
    editTime: "",
    updateTime: "",
  })
//获取登录用户信息
async function getLoginUser(){
  const res= await getLoginUserUsingGet();
  if(res.data.code==200 && res.data.data){
    loginUser.value = res.data.data
  }
}
/**
 * 设置登录用户信息
 * @param newLoginUser 
 */
function setLoginUser(newLoginUser){
    loginUser.value = newLoginUser
}
return {loginUser,getLoginUser,setLoginUser};
})
